﻿using Microsoft.AspNetCore.Mvc;
using WMSUIMVC.Aubit.Procurement;
using WMSUIMVC.DTO.Refund;
using XuanKeZz.Application.HTTP;

namespace WMSUIMVC.Controllers
{
    public class RefundController : Controller
    {

        private readonly IConfiguration configuration;

        public RefundController(IConfiguration configuration)
        {
            this.configuration = configuration;
        }


        public IActionResult Index()
        {
            return View();
        }


        public IActionResult GetRefundList()
        {
            return View();
        }


        /// <summary>
        /// 显示退货列表
        /// </summary>
        /// <param name="model"></param>
        /// <param name="pindex"></param>
        /// <param name="psize"></param>
        /// <returns></returns>
        public async Task<IActionResult> GetRefund(GetRefundDto obj)
        {
            HttpClientWrapper client = new HttpClientWrapper(obj.Token);
            string url = configuration["Url"] + "ywd/api/Refund/GetSalesRefund?RefundCode=" + obj.RefundCode+ "&ProcurementCode="+obj.ProcurementCode+ "&ProductsName=" + obj.ProductsName + "&pindex=" + obj.pindex + "&psize=" + obj.psize;
            var res = await client.GetAsync(url);
            return Json(res);
        }

        /// <summary>
        /// 显示退货列表的详情
        /// </summary>
        /// <param name="model"></param>
        /// <param name="pindex"></param>
        /// <param name="psize"></param>
        /// <returns></returns>
        public async Task<IActionResult> GetRefundDetail(string Token,int RefundId)
        {
            HttpClientWrapper client = new HttpClientWrapper(Token);
            string url = configuration["Url"] + "ywd/api/Refund/GetSalesRefundDetail?RefundId=" + RefundId;
            var res = await client.GetAsync(url);
            return Json(res);
        }


    }
}
